﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_USRegister : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["User"] == null)
        {
            mtvwRegister.ActiveViewIndex = 0;
        }
        else
        {
            mtvwRegister.ActiveViewIndex = 2;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ThanhVien tv = new ThanhVien();
        tv.Email = txtEmail.Text;
        tv.MatKhau = txtMatKhau.Text;
        tv.HoTen = txtHoTen.Text;
        tv.NgSinh = DateTime.Parse(txtNgaySinh.Text);
        tv.DiaChi = txtDiaChi.Text;
        tv.Sodt = txtSDT.Text;
        QuyenBLL quyenbll = new QuyenBLL();

        tv.MaQuyen = quyenbll.GetQuyenById(3);
        ThanhVienBLL itvien = new ThanhVienBLL();
       string st = itvien.InsertMember(tv);
        if (st=="Success")
        {
            HttpContext.Current.Session["User"] = txtEmail.Text;
            mtvwRegister.ActiveViewIndex = 1;
        }
        else if(st=="Fail")
        {
            Response.Write("<script>alert('Them That Bai!')</script>");
        }
        else
        {
             Response.Write("<script>alert('Email đã có người dùng!')</script>");
        }
       
    }
}